home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995 February: Tool Chest / Dev.CD Feb 95 / Dev.CD Feb 95.toast / Tool Chest / Interfaces / Universal Interfaces 2.0a3 / Universal AIncludes / Threads.a < prev    next >
Encoding:
Text File  |  1994-11-11  |  5.1 KB  |  298 lines  |  [TEXT/MPS ]

  1. ;
  2. ;    File:        Threads.a
  3. ;
  4. ;    Copyright:    © 1984-1994 by Apple Computer, Inc.
  5. ;                All rights reserved.
  6. ;
  7. ;    Version:    Universal Interfaces 2.0a3  ETO #16, MPW prerelease.  Friday, November 11, 1994. 
  8. ;
  9. ;    Bugs?:        If you find a problem with this file, send the file and version
  10. ;                information (from above) and the problem description to:
  11. ;
  12. ;                    Internet:    apple.bugs@applelink.apple.com
  13. ;                    AppleLink:    APPLE.BUGS
  14. ;
  15. ;
  16.  
  17.     IF &TYPE('__THREADS__') = 'UNDEFINED' THEN
  18. __THREADS__ SET 1
  19.  
  20.  
  21.     IF &TYPE('__ERRORS__') = 'UNDEFINED' THEN
  22.     include 'Errors.a'
  23.     ENDIF
  24. ;        include 'ConditionalMacros.a'                                ;
  25.  
  26.     IF &TYPE('__MEMORY__') = 'UNDEFINED' THEN
  27.     include 'Memory.a'
  28.     ENDIF
  29. ;        include 'Types.a'                                            ;
  30. ;        include 'MixedMode.a'                                        ;
  31.  
  32. kReadyThreadState                EQU        0
  33. kStoppedThreadState                EQU        1
  34. kRunningThreadState                EQU        2
  35.  
  36. ; Error codes have been meoved to Errors.(pah) 
  37. ; Thread environment characteristics 
  38. ; Thread characteristics 
  39. kCooperativeThread                EQU        1 << 0
  40. kPreemptiveThread                EQU        1 << 1
  41.  
  42. ; Thread identifiers 
  43. kNoThreadID                        EQU        0
  44. kCurrentThreadID                EQU        1
  45. kApplicationThreadID            EQU        2
  46.  
  47. ; Options when creating a thread 
  48. kNewSuspend                        EQU        (1 << 0)
  49. kUsePremadeThread                EQU        (1 << 1)
  50. kCreateIfNeeded                    EQU        (1 << 2)
  51. kFPUNotNeeded                    EQU        (1 << 3)
  52. kExactMatchThread                EQU        (1 << 4)
  53.  
  54. ; Information supplied to the custom scheduler 
  55. SchedulerInfoRec         RECORD    0
  56. InfoRecSize                 ds.l    1
  57. CurrentThreadID             ds.l    1
  58. SuggestedThreadID         ds.l    1
  59. InterruptedCoopThreadID     ds.l    1
  60. sizeof                     EQU    16
  61.                         ENDR
  62.  
  63. ;
  64. ;    The following ProcPtrs cannot be interchanged with UniversalProcPtrs because
  65. ;    of differences between 680x0 and PowerPC runtime architectures with regard to
  66. ;    the implementation of the Thread Manager.
  67. ; Prototype for thread's entry (main) routine 
  68. ; Prototype for custom thread scheduler routine 
  69. ; Prototype for custom thread switcher routine 
  70. ; Prototype for thread termination notification routine 
  71. ; Prototype for debugger NewThread notification 
  72. ; Prototype for debugger DisposeThread notification 
  73. ; Prototype for debugger schedule notification 
  74. ; Thread Manager routines 
  75.     IF GENERATING68K THEN
  76.         Macro
  77.         _CreateThreadPool
  78.             move.w    #$0501,d0
  79.             dc.w     $ABF2
  80.         EndM
  81.     ELSE
  82.         IMPORT    CreateThreadPool
  83.     ENDIF
  84.  
  85.     IF GENERATING68K THEN
  86.         Macro
  87.         _GetFreeThreadCount
  88.             move.w    #$0402,d0
  89.             dc.w     $ABF2
  90.         EndM
  91.     ELSE
  92.         IMPORT    GetFreeThreadCount
  93.     ENDIF
  94.  
  95.     IF GENERATING68K THEN
  96.         Macro
  97.         _GetSpecificFreeThreadCount
  98.             move.w    #$0615,d0
  99.             dc.w     $ABF2
  100.         EndM
  101.     ELSE
  102.         IMPORT    GetSpecificFreeThreadCount
  103.     ENDIF
  104.  
  105.     IF GENERATING68K THEN
  106.         Macro
  107.         _GetDefaultThreadStackSize
  108.             move.w    #$0413,d0
  109.             dc.w     $ABF2
  110.         EndM
  111.     ELSE
  112.         IMPORT    GetDefaultThreadStackSize
  113.     ENDIF
  114.  
  115.     IF GENERATING68K THEN
  116.         Macro
  117.         _ThreadCurrentStackSpace
  118.             move.w    #$0414,d0
  119.             dc.w     $ABF2
  120.         EndM
  121.     ELSE
  122.         IMPORT    ThreadCurrentStackSpace
  123.     ENDIF
  124.  
  125.     IF GENERATING68K THEN
  126.         Macro
  127.         _NewThread
  128.             move.w    #$0E03,d0
  129.             dc.w     $ABF2
  130.         EndM
  131.     ELSE
  132.         IMPORT    NewThread
  133.     ENDIF
  134.  
  135.     IF GENERATING68K THEN
  136.         Macro
  137.         _DisposeThread
  138.             move.w    #$0504,d0
  139.             dc.w     $ABF2
  140.         EndM
  141.     ELSE
  142.         IMPORT    DisposeThread
  143.     ENDIF
  144.  
  145.     IF GENERATING68K THEN
  146.         Macro
  147.         _YieldToThread
  148.             move.w    #$0205,d0
  149.             dc.w     $ABF2
  150.         EndM
  151.     ELSE
  152.         IMPORT    YieldToThread
  153.     ENDIF
  154.  
  155.     IF GENERATING68K THEN
  156.         Macro
  157.         _YieldToAnyThread
  158.             dc.w     $42A7
  159.             move.w    #$0205,d0
  160.             dc.w     $ABF2
  161.         EndM
  162.     ELSE
  163.         IMPORT    YieldToAnyThread
  164.     ENDIF
  165.  
  166.     IF GENERATING68K THEN
  167.         Macro
  168.         _GetCurrentThread
  169.             move.w    #$0206,d0
  170.             dc.w     $ABF2
  171.         EndM
  172.     ELSE
  173.         IMPORT    GetCurrentThread
  174.     ENDIF
  175.  
  176.     IF GENERATING68K THEN
  177.         Macro
  178.         _GetThreadState
  179.             move.w    #$0407,d0
  180.             dc.w     $ABF2
  181.         EndM
  182.     ELSE
  183.         IMPORT    GetThreadState
  184.     ENDIF
  185.  
  186.     IF GENERATING68K THEN
  187.         Macro
  188.         _SetThreadState
  189.             move.w    #$0508,d0
  190.             dc.w     $ABF2
  191.         EndM
  192.     ELSE
  193.         IMPORT    SetThreadState
  194.     ENDIF
  195.  
  196.     IF GENERATING68K THEN
  197.         Macro
  198.         _SetThreadStateEndCritical
  199.             move.w    #$0512,d0
  200.             dc.w     $ABF2
  201.         EndM
  202.     ELSE
  203.         IMPORT    SetThreadStateEndCritical
  204.     ENDIF
  205.  
  206.     IF GENERATING68K THEN
  207.         Macro
  208.         _SetThreadScheduler
  209.             move.w    #$0209,d0
  210.             dc.w     $ABF2
  211.         EndM
  212.     ELSE
  213.         IMPORT    SetThreadScheduler
  214.     ENDIF
  215.  
  216.     IF GENERATING68K THEN
  217.         Macro
  218.         _SetThreadSwitcher
  219.             move.w    #$070A,d0
  220.             dc.w     $ABF2
  221.         EndM
  222.     ELSE
  223.         IMPORT    SetThreadSwitcher
  224.     ENDIF
  225.  
  226.     IF GENERATING68K THEN
  227.         Macro
  228.         _SetThreadTerminator
  229.             move.w    #$0611,d0
  230.             dc.w     $ABF2
  231.         EndM
  232.     ELSE
  233.         IMPORT    SetThreadTerminator
  234.     ENDIF
  235.  
  236.     IF GENERATING68K THEN
  237.         Macro
  238.         _ThreadBeginCritical
  239.             move.w    #$000B,d0
  240.             dc.w     $ABF2
  241.         EndM
  242.     ELSE
  243.         IMPORT    ThreadBeginCritical
  244.     ENDIF
  245.  
  246.     IF GENERATING68K THEN
  247.         Macro
  248.         _ThreadEndCritical
  249.             move.w    #$000C,d0
  250.             dc.w     $ABF2
  251.         EndM
  252.     ELSE
  253.         IMPORT    ThreadEndCritical
  254.     ENDIF
  255.  
  256.     IF GENERATING68K THEN
  257.         Macro
  258.         _SetDebuggerNotificationProcs
  259.             move.w    #$060D,d0
  260.             dc.w     $ABF2
  261.         EndM
  262.     ELSE
  263.         IMPORT    SetDebuggerNotificationProcs
  264.     ENDIF
  265.  
  266.     IF GENERATING68K THEN
  267.         Macro
  268.         _GetThreadCurrentTaskRef
  269.             move.w    #$020E,d0
  270.             dc.w     $ABF2
  271.         EndM
  272.     ELSE
  273.         IMPORT    GetThreadCurrentTaskRef
  274.     ENDIF
  275.  
  276.     IF GENERATING68K THEN
  277.         Macro
  278.         _GetThreadStateGivenTaskRef
  279.             move.w    #$060F,d0
  280.             dc.w     $ABF2
  281.         EndM
  282.     ELSE
  283.         IMPORT    GetThreadStateGivenTaskRef
  284.     ENDIF
  285.  
  286.     IF GENERATING68K THEN
  287.         Macro
  288.         _SetThreadReadyGivenTaskRef
  289.             move.w    #$0410,d0
  290.             dc.w     $ABF2
  291.         EndM
  292.     ELSE
  293.         IMPORT    SetThreadReadyGivenTaskRef
  294.     ENDIF
  295.  
  296.     ENDIF ; __THREADS__
  297.